package com.znyj.cloud.device.util;

import com.znyj.cloud.device.task.model.AbstractTaskModel;

import java.util.Collection;

/**
 * Created by gaoliwei on 15-3-13.
 */
public class ListUtil {

    public static <E> String collection2String(Collection<E> collection) {
        if (null == collection) {
            return "null";
        }

        StringBuilder builder = new StringBuilder();
        builder.append("[");
        for (E e : collection) {
            if (e instanceof AbstractTaskModel) {
                builder.append(((AbstractTaskModel) e).getTaskId());
            } else {
                builder.append(e);
            }
            builder.append(",");
        }
        builder.append("]");
        return builder.toString();
    }
}
